#include <iostream>
#include <cmath>
#include <array>
#include <numeric>

using namespace std;

int main() {
    constexpr unsigned limit = 1'500'000;
    static array<int, limit + 1> arr {0};
    for (unsigned m = 1; m <= sqrt(limit / 2); ++m) {
        for (unsigned n = m + 1; n <= limit / 2; n += 2) {
            if (gcd(m, n) != 1)
                continue;

            unsigned a = n * n - m * m;
            unsigned b = 2 * n * m;
            unsigned c = n * n + m * m;
            unsigned p = a + b + c;
            if (p > limit) 
                break;

            for (unsigned k = 1; k * p <= limit; ++k) 
                ++arr[k * p];
        }
    }    
    int s = 0;
    for (auto e : arr) {
        if (e == 1)
            ++s;
    }
    cout << s << endl;
}